package com.wuneng.ircontrol.module.act;

import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wuneng.ircontrol.R;
import com.wuneng.ircontrol.common.util.Constants;
import com.wuneng.ircontrol.common.util.MyBaseAct;

import butterknife.BindView;
import butterknife.OnClick;

public class LoginAct extends MyBaseAct {
    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.rlBack)
    RelativeLayout rlBack;
    @BindView(R.id.tvRight)
    TextView tvRight;
    @BindView(R.id.btnRight)
    Button btnRight;
    @BindView(R.id.rlTop)
    RelativeLayout rlTop;
    @BindView(R.id.username_et)
    EditText usernameEt;
    @BindView(R.id.password_et)
    EditText passwordEt;
    @BindView(R.id.login_btn)
    Button loginBtn;

    @Override
    protected void bindListener() {

    }

    @Override
    protected void initMyView() {
        tvTitle.setText("管理员登录");
    }

    @Override
    protected void initMyData() {

    }

    @Override
    protected int getMyContentViewLayoutID() {
        return R.layout.act_login;
    }


    @OnClick({R.id.rlBack, R.id.login_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rlBack:
                this.finish();
                break;
            case R.id.login_btn:

                if (TextUtils.isEmpty(usernameEt.getText().toString())) {
                    showToast("请输入用户名");
                    return;
                }

                if (TextUtils.isEmpty(passwordEt.getText().toString())) {
                    showToast("请输入密码");
                    return;
                }


                if (usernameEt.getText().toString().equals(Constants.userName) && passwordEt.getText().toString().equals(Constants.pwd)) {
                    showToast("验证成功");
                    Constants.Login_Tag = true;
                    this.finish();
                }else{
                    showToast("用户名或密码错误");
                }
                break;
        }
    }
}
